﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using Samurai.Infrastructure;
using Samurai.DAL;
using System.Windows;
using Samurai.Client.DataContexts;

namespace Samurai.Client.Commands
{
    public class CommitMovieEditCommand : CommandBase
    {
        private EditMovieDataContext _context;

        public CommitMovieEditCommand(EditMovieDataContext context)
        {
            _context = context;
        }        

        protected override void InvokeExecute(object parameter)
        {
            var movie = (Movie)parameter;

            bool isSuccess = Manager.Instance.UpdateMovie(movie);

            if (isSuccess)
            {
                _context.IsClosed = true;
            }
            else
                MessageBox.Show("Movie couldn't be updated.");
        }
    }
}
